package cn.mazexal.examapi.dataware;

import cn.mazexal.examapi.models.db.StatisticDO;
import cn.mazexal.examapi.models.db.UserWrongDO;

import cn.mazexal.examapi.models.qry.UserCollectQry;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 用户错题本 Mapper
 */
@Mapper
public interface UserWrongMapper extends BaseMapper<UserWrongDO> {


    int deleteUserWrong(@Param("userId") Long userId, @Param("examBankId") Long examBankId,
                        @Param("questionId") Long questionId);

    int updateWrongTimesByQuestionIds(@Param("userId") Long userId, @Param("examBankId") Long examBankId, @Param(
            "questionIds") List<Long> questionIds, @Param("updateTime") Long updateTime);

    List<Long> getUserWrongDeletedQuestionIds(
            @Param("userId") Long userId,
            @Param("examBankId") Long examBankId,
            @Param("questionIds") List<Long> questionIds
    );

    int refuseDelUserWrong(@Param("ids") List<Long> ids, @Param("updateTime") Long updateTime);

    List<Long> getExistUserWrongQuestionIds(
            @Param("userId") Long userId,
            @Param("examBankId") Long examBankId,
            @Param("questionIds") List<Long> questionIds
    );

    int getUserWrongCount(@Param("qry") UserCollectQry qry);

    List<UserWrongDO> getUserWrongList(@Param("qry") UserCollectQry qry);

    List<StatisticDO> getUserStatistic(@Param("examBankId") Long examBankId, @Param("userId") Long userId);
}